﻿using System.Collections.Generic;
using EvoWars.Stuffs;
using EvoWars.Stuffs.TankStuff;
using Microsoft.Xna.Framework;

namespace EvoWars2.Stuffs.TankStuff
{
    public class TankSensor
    {
        public Tank Parent { get; set; }
        public World TheWorld { get; set; }
        public decimal SenceRange { get; set; }



        public TankSensor(Tank parent, World theWorld)
        {
            Parent = parent;
            TheWorld = theWorld;
        }




        public bool CanMoveByVector(Vector2 moveVector)
        {
            bool canMove = true;
            Vector2 previousPosition = Parent.Position;


            Parent.Position = Parent.Position + moveVector;


            //check edge of world
            if (Parent.Position.X < 0 || Parent.Position.X > TheWorld.Width
                || Parent.Position.Y < 0 || Parent.Position.Y > TheWorld.Height)
            {
                canMove = false;
            }



            //check collision with other players

            if (TheWorld.IsPlayerCollidingWithPlayer(Parent))
            {
                canMove = false;
            }

            Parent.Position = previousPosition;
            return canMove;
        }

        public List<Tank> GetSensedEnemies()
        {

            return new List<Tank>();
        }


    }
}
